package com.example.fragment

import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import androidx.fragment.app.Fragment
import com.example.R
import com.example.bus.AndroidJniControl

class GpioPwmFragment : Fragment() {
    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        val view = inflater.inflate(R.layout.fragment_gpio_pwm, container, false)

        view.findViewById<Button>(R.id.test_add).setOnClickListener {
            val result = AndroidJniControl.testAdd(100)
            Log.i("com.example", "jni result java $result");
        }

        view.findViewById<Button>(R.id.open_gpio_button).setOnClickListener {
            AndroidJniControl.setLedState(95,1)
        }
        view.findViewById<Button>(R.id.close_gpio_button).setOnClickListener {
            AndroidJniControl.setLedState(95,0)
        }

        view.findViewById<Button>(R.id.open_pwm_button).setOnClickListener {
            AndroidJniControl.setPwmStart(0,20000000 ,10000000 )
        }

        view.findViewById<Button>(R.id.close_pwm_button).setOnClickListener {
            AndroidJniControl.setPwmStart(0,20000000 ,20000000 )
        }

        return view
    }


}